package br.com.lucasoliveira.modules.comprova;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class EmailCreator {

	public void criaEML(File txtBase, String comprovaID) {
		String name = txtBase.getParent() + File.separatorChar + comprovaID
				+ ".eml";
		File eml = new File(name);
		try {
			copia(txtBase, eml);
		} catch (IOException ioe) {
			System.out.println("Erro ao copiar");
		}
	}

	private void copia(File txtBase, File eml) throws IOException {
		InputStream in = new FileInputStream(txtBase);
		OutputStream out = new FileOutputStream(eml);
		byte[] buf = new byte[1024];
		int len;
		while ((len = in.read(buf)) > 0) {
			out.write(buf, 0, len);
		}
		in.close();
		out.close();
	}
}
